﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="companyPriceStructure.aspx.cs"
    Inherits="PeisongWeb.admin.companyPriceStructure" %>

<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<%@ Register TagName="menu" Src="controls/menu.ascx" TagPrefix="uc2" %>
<%@ Register TagName="top" Src="controls/top.ascx" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>企业价格体系初始化</title>
    <!--#include file="style.inc"-->

    <script type="text/javascript" language="javascript" src="../app_common/scripts/jquery-cn.js"></script>

    <script type="text/javascript">
        //        function isNumberFlag(s, spe) {
        //            var i;
        //            for (i = 0; i < s.length; i++) {
        //                // Check that current character is number.
        //                var c = s.charAt(i);
        //                if (c != spe) {
        //                    if (((c < "0") || (c > "9")))
        //                        return false;
        //                }

        //            }
        //            // All characters are numbers.
        //            return true;
        //        }

        //        function checkNum2(obj) {


        //            if (isNumberFlag(obj.value, ".") == false && obj.value != "" && obj.value!="0")
        //                obj.value = obj.value.replace(/\D/g, '');
        ////            else
        ////                obj.value = "";
        //        }

        function checkNum(obj) {
            if (obj.value.length != 0) {
                //obj.value = obj.value.replace(/\D/g, '');
                if (/^(-)?[0-9]\d*$/.test(obj.value)) {
                } else {
                    obj.value = "0";
                    obj.focus();
                }
            }
            else
                obj.value = "0";
        }

        function getPriceStructure() {
            var percents = "";

            $("input[id^='input_percent_']").each(function(i, n) {
                var val = parseInt($(n).val()) / 100;
                var categoryId = $(n).attr("id");
                categoryId = categoryId.replace("input_percent_", "");

                if (val == "") {
                    val = 0;
                }
                if (i == 0) {
                    percents += categoryId + "|" + val;
                }
                else {
                    percents += "," + categoryId + "|" + val;
                }
            });

            //alert(percents);
            $("#hd_pricePercent").val(percents);
            //return false;
        }
        
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <ext:ScriptManager ID="ScriptManager1" runat="server" />
    <uc1:top ID="Top1" runat="server" />
    <uc2:menu ID="Menu1" runat="server" />
    <div id="admin_main" style="margin: 10px 0 0 10px;">
        <ext:Panel ID="Panel2" runat="server" Title="采购商价格体系初始化" BodyStyle="padding:5px 5px 0"
            Width="600" Frame="true" ButtonAlign="Center">
            <Body>
                <div id="admin_edit_content">
                    <ul>
                        <li style="width: 400px; border-bottom: 2px solid #99bbe8; float: left">
                            <label style="width: 50px; font-weight: bold;">
                                公司名:
                            </label>
                            <asp:Label CssClass="red" runat="server" ID="lbl_CompanyName"></asp:Label>
                        </li>
                        <li style="width: 100px; padding-left: 50px"><span style="<%=power>=2?"": "display:none" %>">
                            <asp:LinkButton ID="lbn_Import" runat="server" Text="［导出 Excel］" CausesValidation="false"
                                OnClick="lbn_Import_Click">
                            </asp:LinkButton>
                        </span></li>
                    </ul>
                    <ul>
                        <asp:Repeater ID="rpt_list" runat="server">
                            <ItemTemplate>
                                <li style="font-weight: bold; margin-top: 10px; font-style: italic; font-size: 14px;
                                    border-bottom: 1px solid #99bbe8; width: 100%; <%#Eval("parentId").ToString()=="0"?"": "display:none" %>">
                                    <label style="width: 150px;">
                                        <div style="margin-left: 20px;">
                                            <%#Eval("name")%></div>
                                    </label>
                                    <span style="font-style: normal; font-size: 12px;">加价比例<%--(例如:0.30表示30%)--%></span>
                                </li>
                                <li style="<%#Container.ItemIndex%2==0?"background-color:White;": "" %><%#Eval("parentId").ToString()=="0"?"display:none":"" %>">
                                    <label style="width: 150px;">
                                        <div style="margin-left: 20px;">
                                            <%#Eval("name")%></div>
                                    </label>
                                    <input onblur='checkNum(this);' onafterpaste='checkNum(this);' style='text-align: right;
                                        width: 20px;' maxlength='3' id='input_percent<%#Eval("parentId").ToString()=="0"?"0":"" %>_<%#Eval("categoryId")%>'
                                        type='text' value='<%# Convert.ToDouble(Eval("currentPercent"))*100%>'>%
                                    <%-- &nbsp;&nbsp;&nbsp;<a href="#"><span>设置<%#Eval("name")%>商品加价比例</span></a>--%>
                                </li>
                            </ItemTemplate>
                        </asp:Repeater>
                        <li>
                            <label style="width: 150px;">
                                &nbsp;
                            </label>
                            <span style="<%=power>=2?"": "display:none" %>">
                                <asp:Button ID="bt_save" runat="server" OnClientClick="return getPriceStructure();"
                                    Text="保存" OnClick="bt_save_Click" />
                            </span>
                            <input type="button" value="返回" onclick="javascript:window.location.href='companyList.aspx';" />
                            <input type="hidden" runat="server" id="hd_pricePercent" />
                        </li>
                    </ul>
                </div>
            </Body>
        </ext:Panel>
    </div>
    </form>
</body>
</html>
